<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>广播</title>
    <link rel="stylesheet" type="text/css" href="/zhaojun/layui/css/layui.css" />
</head>
<body>

<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
    <legend>广播消息</legend>
</fieldset>

<form class="layui-form" action="">
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">广播内容</label>
        <div class="layui-input-block">
            <textarea placeholder="请输入内容" class="layui-textarea" id ="value"></textarea>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit="" lay-filter="submit">提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>

</body>
<script src="/zhaojun/layui/layui.js" type="text/javascript" charset="utf-8"></script>
<script>
    layui.use(['form','layer'], function(){
        var form = layui.form;
        var layer = layui.layer;
        var $ = layui.jquery;

        form.render();

        //监听提交
        form.on('submit(submit)', function () {
            var load = layer.load(2);
            var value =  $("#value").val();
            var message= new Object();
            message.content = value;
            message.action = '2';
            message.sender = 'system';
            message.format = 0;

            $.ajax({
                url: 'http://127.0.0.1:8031/zhaojun-service-im/api/message/broadcasting',
                type: 'POST',
                data: message,
                success: function(){
                    layer.close(load);
                    layer.alert('消息已广播');
                }
            });
            return false;
        });
    });

</script>
</html>